//
//  VisitorTableViewController.swift
//  HMWeibo
//
//  Created by wulei on 15/12/6.
//  Copyright © 2015年 wulei. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {
/// 用户登陆标记
    
 private var userLogin = HMUserAccountViewModel.sharedUserAccountViewModel.isLogon
    
    // 访客视图
    var visitorView: VisitorView?
    
    override func loadView() {
//        super.loadView()
        
        userLogin ? super.loadView(): setupVisitorView()
        

    }
    
    
    
/// 设置访客视图
   private func setupVisitorView() {
    
    visitorView = VisitorView()
visitorView?.registerButton .addTarget(self, action: "visitorViewDidRegister", forControlEvents: .TouchUpInside)
    visitorView?.loginButton.addTarget(self, action: "visitorViewDidLogin", forControlEvents: .TouchUpInside)

    view = visitorView
    
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorViewDidRegister")
    navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorViewDidLogin")


    }
}

extension VisitorTableViewController {
    func visitorViewDidRegister() {
//        print("注册")
    }
    
    func visitorViewDidLogin() {
        
        let VC = HMOAuthViewController()
        let nav = UINavigationController(rootViewController: VC)
        
        presentViewController(nav, animated: true, completion: nil)
        
//        print("登陆")
    }
}